#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>
using namespace std;
void algorithm(string& prev, string& curr, string& res) {
    short m = curr.size()-2;
    string next(m+2, '0');
    size_t pos = 1;
    while(pos <= m) {
        if(curr[pos] == '*') {
                curr[pos+1] != '*' ? curr[pos+1] = 1 + res[pos+1]   : 0;
                curr[pos-1] != '*' ? curr[pos-1]++                  : 0;
                prev[pos]   != '*' ? prev[pos]++                    : 0;
                prev[pos+1] != '*' ? prev[pos+1]++                  : 0;
                prev[pos-1] != '*' ? prev[pos-1]++                  : 0;
                next[pos]++;
                next[pos+1]++;
                next[pos-1]++;
        } else if(curr[pos] == '.'){
            curr[pos] = res[pos];
        }
        pos++;
    }
    res = next;
}

/* main
 * */

int main() {
	std::ios_base::sync_with_stdio (true);
    long fields = 0;
    string curr;
    string prev;
    string res;
    curr.reserve(120);
    prev.reserve(120);
    res.reserve(120);
    while ( true ) {
        unsigned long n =0;
        unsigned long m =0;
        cin >> n >> m;
        if (n == 0 && m == 0) { 
            return 0;
        }
        prev= string(m+2, '0');
        res = string(m+2, '0');
        if(fields != 0) 
            cout << endl;
        fields++;
        cout << "Field #" << fields <<":" << endl;
		cin >> curr;
		curr = '0'+curr+'0';
		algorithm(prev, curr, res);
		prev = curr;
        for (short i = 1; i < n; i++) {
            cin >> curr;
			curr = '0'+curr+'0';
            algorithm(prev, curr, res);
			copy(prev.begin()+1, prev.begin()+m+1, ostream_iterator<char>(cout, ""));
			cout << endl;
            prev = curr;
        }
		copy(prev.begin()+1, prev.begin()+m+1, ostream_iterator<char>(cout, ""));
        cout << endl;
    }
}

